﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>智税-后台管理中心</title>
    <link rel="stylesheet" href="Content/src/css/layui.css" media="all">

</head>
<body>
    <div class="layui-tab layui-tab-brief main-tab-container ">
        <div class="layui-tab-content">
            <button class="layui-btn layui-btn-normal layui-btn-small demo" data-type="add"><i class="layui-icon">&#xe605;</i> 审 批 </button>
            <button class="layui-btn layui-btn-warm layui-btn-small demodetail" data-type="edit"><i class="layui-icon">&#xe642;</i> 详 情 </button>
            <button class="layui-btn layui-btn-danger layui-btn-small" lay-submit lay-filter="delete"><i class="layui-icon">&#xe640;</i> 删 除 </button>
        </div>
        <div class="layui-form layui-tab-content">
            <table class="layui-table">
                <colgroup>
                    <col width="80">
                </colgroup>
                <thead>
                    <tr>
                        <th><input name="checkAll" lay-skin="primary" type="checkbox" lay-filter="checkAll"></th>
                        <th>序号</th>
                        <th>街办</th>
                        <th>社区</th>
                        <th>楼宇</th>
                        <th>单元</th>
                        <th>房号</th>
                        <th>身份证</th>
                        <th>付款证明</th>
                        <th>房产证</th>
                        <th>租房合同</th>
                        <th>审核人</th>
                        <th>审核时间</th>
                        <th>审批状态</th>
                        <th>审批意见</th>
                    </tr>
                </thead>
                <tbody id="showNewList"></tbody>
            </table>
        </div>
    </div>
   
    <!-- Mode -->
    <div id="add_edit" style="display: none; padding-right: 20px; padding-top: 20px;">
        <form class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">审批结果：</label>
                <div class="layui-input-block">
                    <input type="radio" name="apply" value="1" title="通过" checked>
                    <input type="radio" name="apply" value="2" title="拒绝">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">审批意见：</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" name="content" id="Info_Mation"></textarea>
                </div>
            </div>
            <div class="layui-form-item" style="text-align: right;">
                <div class="layui-btn layui-btn-normal" lay-submit lay-filter="btnSubmit">提 交</div>
            </div>
        </form>
    </div>


    <div id="detail" style="display: none; padding-right: 20px; padding-top: 20px;">
        <form class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">街办</label>
                <div class="layui-input-block">
                    <input type="text" id="Dt_ParentName" readonly class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">社区</label>
                <div class="layui-input-block">
                    <input type="text" id="Dt_Name" readonly class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">楼宇</label>
                <div class="layui-input-block">
                    <input type="text" id="Bd_Name" readonly class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">单元</label>
                <div class="layui-input-block">
                    <input type="text" id="Uim_Name" readonly class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">房号</label>
                <div class="layui-input-block">
                    <input type="text" id="Hs_Number" readonly class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">身份证：</label>
                <div class="layui-input-block">
                    <img src="" alt="" id="Property_IDNumber" width="500" height="300" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">付款证明：</label>
                <div class="layui-input-block">
                    <img src="" alt="" id="Property_PaymentCertificate" width="500" height="300" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">租房合同：</label>
                <div class="layui-input-block">
                    <img src="" alt="" id="Property_LeaseContract" width="500" height="300" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">房产证：</label>
                <div class="layui-input-block">
                    <img src="" alt="" id="Property_Card" width="500" height="300"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">审核状态</label>
                <div class="layui-input-block">
                    <input type="text" id="AuditStatus" readonly class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">审核人</label>
                <div class="layui-input-block">
                    <input type="text" id="AuditUserName" readonly class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">审核时间</label>
                <div class="layui-input-block">
                    <input type="text" id="AuditTime" readonly class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">审核意见</label>
                <div class="layui-input-block">
                    <input type="text" id="AuditMeg" readonly class="layui-input">
                </div>
            </div>
        </form>
    </div>
    <script type="text/javascript" src="Content/src/layui.js"></script>
    <script src="Content/js/zor_base.js"></script>
    <script type="text/javascript">
        layui.use(['element', 'layer', 'form', 'layedit'], function () {
            var element = layui.element()
            , jq = layui.jquery
            , form = layui.form()
            , layedit = layui.layedit
            , laypage = layui.laypage;

            //加载推送信息
            jq(document).ready(function () {
                if (localStorage.getItem("username") == "" || localStorage.getItem("username") == null) {
                    window.location.href = "login.html";
                } else {
                    var Apply = {
                        Dt_ParentId: localStorage.getItem("dtparentId")
                    };
                    loading = layer.load();
                    jq.ajax({
                        url: '/api/CredentialInfo/PushMegList',
                        type: 'POST',
                        contentType: "application/json",
                        dataType: "json",
                        data: JSON.stringify(Apply),
                        success: function (data) {
                            var html = '';
                            var accordionMenu = data;
                            jq.each(accordionMenu, function (i) {
                                html += "<tr>";
                                html += "<td><input name='' lay-skin='primary' type='checkbox' lay-filter='checkOne' role-id='" + accordionMenu[i].Property_Id +
                                        "' role-apply='"+ accordionMenu[i].AuditStatus +
                                        "' role-dtparentname='" + accordionMenu[i].Dt_ParentName +
                                        "' role-dtname='" + accordionMenu[i].Dt_Name +
                                        "' role-bdname='" + accordionMenu[i].Bd_Name +
                                        "' role-uimname='" + accordionMenu[i].Uim_Name +
                                        "' role-hsnumber='" + accordionMenu[i].Hs_Number +
                                        "' role-pc='" + accordionMenu[i].Property_Card +
                                        "' role-pi='" + accordionMenu[i].Property_IDNumber +
                                        "' role-pl='" + accordionMenu[i].Property_LeaseContract +
                                        "' role-pp='" + accordionMenu[i].Property_PaymentCertificate +
                                        "' role-auditusername='" + accordionMenu[i].AuditUserName +
                                        "' role-audittime='" + accordionMenu[i].AuditTime +
                                        "' role-auditmeg='" + accordionMenu[i].AuditMeg + "'></td>";
                                html += "<td>" + (i + 1) + "</td>";
                                html += "<td>" + accordionMenu[i].Dt_ParentName + "</td>";
                                html += "<td>" + accordionMenu[i].Dt_Name + "</td>";
                                html += "<td>" + accordionMenu[i].Bd_Name + "</td>";
                                html += "<td>" + accordionMenu[i].Uim_Name + "</td>";
                                html += "<td>" + accordionMenu[i].Hs_Number + "</td>";
                                if (accordionMenu[i].Property_Card == "" || accordionMenu[i].Property_Card == null) {
                                    html += "<td>无</td>";
                                } else {
                                    html += "<td>有</td>";
                                }
                                if (accordionMenu[i].Property_IDNumber == "" || accordionMenu[i].Property_IDNumber == null) {
                                    html += "<td>无</td>";
                                } else {
                                    html += "<td>有</td>";
                                }
                                if (accordionMenu[i].Property_LeaseContract == "" || accordionMenu[i].Property_LeaseContract == null) {
                                    html += "<td>无</td>";
                                } else {
                                    html += "<td>有</td>";
                                }
                                if (accordionMenu[i].Property_PaymentCertificate == "" || accordionMenu[i].Property_PaymentCertificate == null) {
                                    html += "<td>无</td>";
                                } else {
                                    html += "<td>有</td>";
                                }
                                html += "<td>" + (accordionMenu[i].AuditUserName == null ? " " : accordionMenu[i].AuditUserName) + "</td>";
                                html += "<td>" + (accordionMenu[i].AuditTime == '0001-01-01T00:00:00' ? " " : accordionMenu[i].AuditTime) + "</td>";
                                if (accordionMenu[i].AuditStatus == 0)
                                    html += "<td>未审核</td>";
                                else if (accordionMenu[i].AuditStatus == 1)
                                    html += "<td>审核通过</td>";
                                else
                                    html += "<td>驳回</td>";
                                html += "<td>" + (accordionMenu[i].AuditMeg == null ? "/" : accordionMenu[i].AuditMeg) + "</td>";
                                html += "</tr>";
                            });

                            jq('#showNewList').empty().append(html);
                            form.render('checkbox');
                            layer.close(loading);
                        }
                    });
                }
            });


            //监听提交- 删除
            form.on('submit(delete)', function (data) {
                //判断是否有选项
                var ary = check(jq);
                if (ary.length == 0) {
                    layer.msg('请选择要删除的数据！');
                    return false;
                }
                if (ary[0].AuditStatus != "2") {
                    layer.msg('只能删除驳回的数据！');
                    return false;
                }

                layer.confirm("确认删除吗", { icon: 2, btn: ['确定', '取消'] }, function (index, layero) {
                    jq.ajax({
                        type: 'post',
                        url: '/api/PropertyInfo/DelPushMeg',
                        contentType: "application/json",
                        data: JSON.stringify({ 'ids': ary }),
                        dataType: "json",
                        success: function (data) {
                            if (data.AnswerType == 1) {
                                layer.close(loading);
                            }
                            layer.msg(data.AnswerMeg, function () {
                                location.reload();
                                return false;
                            });
                            Replace();
                        }
                    });
                });
            });


            //全选
            form.on('checkbox(checkAll)', function (data) {
                if (data.elem.checked) {
                    jq("input[type='checkbox']").prop('checked', true);
                } else {
                    jq("input[type='checkbox']").prop('checked', false);
                }
                form.render('checkbox');
            });


            //单选
            form.on('checkbox(checkOne)', function (data) {
                var is_check = true;
                if (data.elem.checked) {
                    jq("input[lay-filter='checkOne']").each(function () {
                        if (!jq(this).prop('checked')) { is_check = false; }
                    });
                    if (is_check) {
                        jq("input[lay-filter='checkAll']").prop('checked', true);
                    }
                } else {
                    jq("input[lay-filter='checkAll']").prop('checked', false);
                }
                form.render('checkbox');
            });


            //显示弹出框 - 增加、修改
            jq('.demo').on('click', function () {
                var ary = check(jq);
                if (ary.length == 0 || ary.length > 1) {
                    layer.msg('必须选择一行数据！');
                    return;
                }

                layer.open({
                    title: "审批",
                    type: 1,
                    skin: 'layui-layer-rim',
                    area: ['700px', '360px'],
                    content: jq('#add_edit')
                });

            });

            //显示弹出框 - 详情
            jq('.demodetail').on('click', function () {
                var ary = check(jq);
                if (ary.length == 0 || ary.length > 1) {
                    layer.msg('必须选择一行数据！');
                    return;
                }
                layer.open({
                    title: "详情",
                    type: 1,
                    skin: 'layui-layer-rim',
                    area: ['700px', '530px'],
                    content: jq('#detail'),
                    success: function () {
                        jq('#Dt_ParentName').val(ary[0].Dt_ParentName);
                        jq('#Dt_Name').val(ary[0].Dt_Name);
                        jq('#Bd_Name').val(ary[0].Bd_Name);
                        jq('#Uim_Name').val(ary[0].Uim_Name);
                        jq('#Hs_Number').val(ary[0].Hs_Number);
                        if (ary[0].AuditStatus == 0) {
                            jq('#AuditStatus').val("未审核");

                        } else if (ary[0].AuditStatus == 1) {
                            jq('#AuditStatus').val("审核通过");
                            jq('#AuditUserName').val(ary[0].AuditUserName == null ? "" : ary[0].AuditUserName);
                            jq('#AuditMeg').val(ary[0].AuditMeg == null ? "" : ary[0].AuditMeg);
                            jq('#AuditTime').val(ary[0].AuditTime == '0001-01-01T00:00:00' ? " " : ary[0].AuditTime);
                        } else {
                            jq('#AuditStatus').val("驳回");
                            jq('#AuditUserName').val(ary[0].AuditUserName == null ? "" : ary[0].AuditUserName);
                            jq('#AuditMeg').val(ary[0].AuditMeg == null ? "" : ary[0].AuditMeg);
                            jq('#AuditTime').val(ary[0].AuditTime == '0001-01-01T00:00:00' ? " " : ary[0].AuditTime);
                        }
                        
                        if (ary[0].Property_Card == "" || ary[0].Property_Card == null) {

                        } else {
                            jq('#Property_Card').attr("src", ary[0].Property_Card);
                        }
                        if (ary[0].Property_IDNumber == "" || ary[0].Property_IDNumber == null) {

                        } else {
                            jq('#Property_IDNumber').attr("src", ary[0].Property_IDNumber);
                        }
                        if (ary[0].Property_LeaseContract == "" || ary[0].Property_LeaseContract == null) {

                        } else {
                            jq('#Property_LeaseContract').attr("src", ary[0].Property_LeaseContract);
                        }
                        if (ary[0].Property_PaymentCertificate == "" || ary[0].Property_PaymentCertificate == null) {

                        } else {
                            jq('#Property_PaymentCertificate').attr("src", ary[0].Property_PaymentCertificate);
                        }
                    }
                });

            });

            //提交新增、编辑
            form.on('submit(btnSubmit)', function (data) {
                var ary = check(jq);

                var Apply = {
                    Credential_Id: ary[0].Property_Id,
                    AuditStatus: jq('input:radio[name="apply"]:checked').val(),
                    AuditMeg: jq('#Info_Mation').val(),
                    AuditUserId: localStorage.getItem("userid")
                };

                loading = layer.load();

                jq.ajax({
                    url: '/api/CredentialInfo/ApplyPushMeg',
                    type: 'POST',
                    contentType: "application/json",
                    dataType: "json",
                    data: JSON.stringify(Apply),
                    success: function (data) {
                        if (data.AnswerType == 1) {
                            layer.close(loading);
                        }
                        layer.msg(data.AnswerMeg, function () {
                            Replace();
                        });
                    }
                });

            });

            //返回 选择行的值
            function check() {
                var ary = new Array();
                jq("input[lay-filter='checkOne']").each(function () {
                    if (jq(this).prop('checked')) {
                        var ckindex = jq(this).attr('role-id');
                        var ckapply = jq(this).attr('role-apply');
                        var ckdtparentname = jq(this).attr('role-dtparentname');
                        var ckdtname = jq(this).attr('role-dtname');
                        var ckbdname = jq(this).attr('role-bdname');
                        var ckuimname = jq(this).attr('role-uimname');
                        var ckhsnumber = jq(this).attr('role-hsnumber');
                        var ckpc = jq(this).attr('role-pc');
                        var ckpi = jq(this).attr('role-pi');
                        var ckpl = jq(this).attr('role-pl');
                        var ckpp = jq(this).attr('role-pp');
                        var ckauditusername = jq(this).attr('role-auditusername');
                        var ckaudittime = jq(this).attr('role-audittime');
                        var ckauditmeg = jq(this).attr('role-auditmeg');
                        ary.push({
                            Property_Id: ckindex, AuditStatus: ckapply, Dt_ParentName: ckdtparentname, Dt_Name: ckdtname,
                            Bd_Name: ckbdname, Uim_Name: ckuimname, Hs_Number: ckhsnumber, Property_Card: ckpc,
                            Property_IDNumber: ckpi, Property_LeaseContract: ckpl, Property_PaymentCertificate: ckpp,
                            AuditUserName: ckauditusername, AuditTime: ckaudittime, AuditMeg: ckauditmeg});
                    }
                });
                return ary;
            }
        })
    </script>

</body>
</html>
